var router = require('koa-router')();
var superagent = require('superagent-promise')(require('superagent'), Promise);
var cheerio = require('cheerio');
var db=require("../orm/db");
/*
router=new router({
    prefix:'/users'
})
*/

router.get('/', function (ctx, next) {

  ctx.body = 'this a users response!';
});
router.get('/test/:id/:cat',async (ctx,next)=>{
    console.log(ctx.params)
    let res=await superagent.get('http://ip.taobao.com/service/getIpInfo.php?ip=114.91.82.183')
    //let $ = cheerio.load(res.text);
    //let temp='{"name":"json","age":"23"}'
    ctx.state={
        title:'test',
        res:JSON.stringify(res),
        params:JSON.stringify(ctx.params)
    };
    await ctx.render('test',{})
})

module.exports = router;
